import os


# 定义一个函数来处理目录及其子目录下的文件
def rename_htm_to_html(directory):
    for root, dirs, files in os.walk(directory):
        for file in files:
            if file.endswith('.htm'):
                # 构建原始文件路径和目标文件路径
                original_path = os.path.join(root, file)
                new_file = file.replace('.htm', '.html')
                new_path = os.path.join(root, new_file)

                # 重命名文件
                os.rename(original_path, new_path)
                print(f"Renamed '{original_path}' to '{new_path}'")


if __name__ == '__main__':
    # 指定要处理的目录
    directory_to_search = '/tmp'
    
    # 调用函数来处理目录及其子目录下的文件
    rename_htm_to_html(directory_to_search)
